﻿/// ****************************************************************************
/// Author:	        Robin Zhu
/// Create Date:	2013-11-4
/// Purpose: 		应用的功能组集合
/// ****************************************************************************
/// Modify By		Date			Remark
/// ****************************************************************************
///
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RB.Web.Security.Rdb
{
    /// <summary>
    /// 应用的功能组集合
    /// </summary>
    public class PermissionGroupSet : RB.Domain.RelationalMapping.KeyedRecordSet<PermissionGroup, string>
    {
        public override bool Contains(PermissionGroup item)
        {
            return this.Any(t => t.Code == item.Code);
        }

        public override bool Remove(PermissionGroup item, DataAccess.Executor exec)
        {
            int count = this.RemoveAll(t => t.Code == item.Code, exec);
            return count > 0;
        }

        public override PermissionGroup this[string key]
        {
            get
            {
                return this.FirstOrDefault(t => t.Code == key);
            }
            set
            {
                this.Update(t => value, t => t.Code == key);
            }
        }
    }
}
